<?php
// +----------------------------------------------------------------------
// | 众联TK架构 [ ZoomTk ]
// +----------------------------------------------------------------------
// | 版权所有 2017~2037 成都众联思索科技有限公司 [ http://www.zoomtk.com ]
// +----------------------------------------------------------------------
// | 官方网站: http://www.sopvip.com
// +----------------------------------------------------------------------
// | 开源协议 ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------

namespace app\member\validate;

use think\Validate;

/**
 * 用户验证器
 * @package app\admin\validate
 * @author Sunday <153788231@qq.com>
 */
class User extends Validate
{
    //定义验证规则
    protected $rule = [
        'member_name|用户名' => 'require|unique:member_user',
        'nickname|昵称'  => 'require',
        'member_email|邮箱'     => 'email',
        'member_passwd|密码'  => 'require|length:6,20',
        'member_mobile|手机号'   => 'regex:^1\d{10}',
    ];

    //定义验证提示
    protected $message = [
        'member_name.require' => '请输入用户名',
        'member_email.require'    => '邮箱不能为空',
        'member_email.email'      => '邮箱格式不正确',
        'member_email.unique'     => '该邮箱已存在',
        'member_passwd.require' => '密码不能为空',
        'member_passwd.length'  => '密码长度6-20位',
        'member_mobile.regex'     => '手机号不正确',
    ];

    //定义验证场景
    protected $scene = [
        //更新
        'update'  =>  ['member_email', 'member_passwd' => 'length:6,20', 'member_mobile'],
        //登录
        'signin'  =>  ['member_name' => 'require', 'member_passwd' => 'require'],
    ];
}
